package com.ym.jiujiangeyou.ui;

import com.ym.jiujiangeyou.R;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
 /**   
 * @author 叶铭   
 * @email yeming_1001@163.com
 * @version V1.0  
 * @Description: 自定义 提示框
 */
public class DialogView {

	public DialogView() {
	}

	/** 
	* @param context
	* @retur  Dialog 
	* @Description: 自定义Dialog
	*/
	public static Dialog popDialog(Context context,int resId){
		//	Dialog dialog = new Dialog(this, R.style.dialog) ;
			Dialog dialog = new Dialog(context, R.style.mydialog) ;
			View view = LayoutInflater.from(context).inflate(R.layout.my_dialog, null) ;
		//	dialog.setContentView(R.layout.dialog) ;
			dialog.setContentView(view) ;
			ImageView imageView = (ImageView) view.findViewById(R.id.imageView1) ;
			TextView textView = (TextView) view.findViewById(R.id.dialog_msg) ;
			textView.setText(resId) ;
			imageView.setBackgroundResource(R.anim.loading) ;
			AnimationDrawable drawable = (AnimationDrawable) imageView.getBackground() ;
			drawable.start() ;
		//	dialog.show() ;
			return dialog ;
		}
	
	/** 
	* @param context
	* @param msg
	* @retur  Toast 
	* @Description: 自定义toast提示框 
	*/
	@SuppressLint("ShowToast")
	public static Toast popToast(Context context,int resId){
		Toast toast = new Toast(context) ;
		View view = LayoutInflater.from(context).inflate(R.layout.my_toast, null) ;
		TextView textView = (TextView) view.findViewById(R.id.tv_toast) ;
		textView.setText(resId) ;
		toast.setView(view) ;
	//	toast.setText(resId) ;
	//	Toast.makeText(context, resId, Toast.LENGTH_LONG) ;
		toast.setDuration(Toast.LENGTH_LONG) ;
		toast.setGravity(Gravity.CENTER, 0, 0) ;
		//toast.show() ;
		return toast ;
	}
	
	/** 
	* @param context
	* @param resId
	* @return  
	* @retur  Dialog 
	* @Description: 自定义弹出dialog
	*/
	public static AlertDialog Alertdialog(Context context,int resId){
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.alert_dialog_view, null) ;
		TextView textView = (TextView) view.findViewById(R.id.dialog_text) ;
		textView.setText(resId) ;
		AlertDialog dialog = new AlertDialog.Builder(context).create();
		dialog.setContentView(view) ;
		return dialog ;
	}
}
